import { OhosModuleContext } from "@ohos/hvigor-ohos-plugin/src/plugin/context/plugin-context";
import RouterClassParser from "./RouterClassParser";
import { hvigor, HvigorNode } from "@ohos/hvigor";
import RouterGenerator from "./RouterGenerator";
import { Logger } from "../utils/Logger";

export function generator(
  context: OhosModuleContext,
  node: HvigorNode,
  pluginId: string
) {
  const parser = new RouterClassParser(context, node);
  const routerServiceConfig = parser.parse();

  if (!routerServiceConfig) {
    return;
  }

  const generator = new RouterGenerator(
    context,
    node,
    pluginId,
    routerServiceConfig
  );
  generator.generator();
}
